package net.hands.ado.db.jdbc.dialect;

public class OracleFunction extends SQLFunction {

	@Override
	public String substring(String str, Integer s, int l) {
		
		return getSb().append(" substr(").append(str)
				.append(s != null ? "," + s : "").append(",").append(l)
				.append(") ").toString();
	}

	@Override
	public String locate(String str, String colName, Integer s) {
		
		return getSb().append(" instr(").append(str).append(",")
				.append(colName).append(s != null ? "," + s : "").append(") ")
				.toString();
	}

	@Override
	public String ascii(String str) {
		
		return getSb().append(" ascii(").append(str).append(") ").toString();
	}

	@Override
	public String ln(String str) {
		return getSb().append(" ln(").append(str).append(") ").toString();
	}

	@Override
	public String log(String b, String x) {
		if (b == null) {
			return getSb().append(" log(").append(x).append(") ").toString();
		} else {
			return getSb().append(" log(").append(b).append(",").append(x)
					.append(") ").toString();
		}
	}

	@Override
	public String tan(String str) {
		return getSb().append(" tan(").append(str).append(") ").toString();
	}

	@Override
	public String round(String x, int d) {
		if (d != 0) {
			return getSb().append(" round(").append(x).append(",").append(d)
					.append(") ").toString();
		}
		return getSb().append(" round(").append(x).append(") ").toString();
	}
}
